using UnityEngine;

public class SingularityBall : PoolBall
{
	public static Delegate1Args<PoolBall> SingularityBreakBall;

	[SerializeField]
	private GameObject m_BreakEffect;

	private string m_PoolKey = "BreakEffect";

	public override void Start()
	{
		base.Start();
		SceneInitialization.Instance.InitObject(m_PoolKey, 5, m_BreakEffect);
	}

	public override void OnCollisionEnter(Collision col)
	{
		if (col.gameObject.name.Contains("Rail"))
		{
			AudioManager.BallhitRail(m_Rigidbody.velocity);
			if (!hitWall)
			{
				GameManager.Rules.BallHitRail(this);
				hitWall = true;
			}
		}
		if (!col.gameObject.CompareTag("Ball"))
		{
			return;
		}
		PoolBall component = col.transform.GetComponent<PoolBall>();
		if (component.ballType != 0 && component.ballType != BallType.JIANGYOU && component.ballType != BallType.ABSORB && base.BallState == State.ROLL)
		{
			Transform transform = SceneInitialization.Instance.GetObject(m_PoolKey).transform;
			transform.position = base.transform.position;
			if (SingularityBreakBall != null)
			{
				SingularityBreakBall(component);
			}
			AudioManager.Break();
		}
		else if ((m_state & (State.POTTED | State.HIDE)) == State.NONE || (col.gameObject.GetComponent<PoolBall>().BallState & (State.POTTED | State.HIDE)) == State.NONE)
		{
			AudioManager.BallhitBall(m_Rigidbody.velocity);
		}
	}
}
